﻿using System;
using Glue;
using Glue.Internals.Verification;
using Xunit;

namespace GlueTests.MapperVerificationTests
{
    public class When_mapping_towards_valuetype_using_converter
    {
        public class DomainPerson { public int Id { get; set; } }
        public class GuiPerson { public String Id { get; set; } }

        private readonly Mapping<DomainPerson, GuiPerson> mapping;
        private readonly MapperVerification<DomainPerson, GuiPerson> verification;
        private readonly Random random = new Random(Environment.TickCount);

        public When_mapping_towards_valuetype_using_converter()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.AddConverter(Converting.BetweenIntAndString());
            mapping.AutoRelateEqualNames();
            verification = new MapperVerification<DomainPerson, GuiPerson>(mapping);
            verification.AddRandomizer(typeof(String),()=> random.Next().ToString() );
        }

        [Fact]
        public void Should_map_normally()
        {
            Assert.Equal(1,mapping.Relations.Count);
            verification.AssertMapsCorrectlyTowards(new DomainPerson());
        }
    }
}
